<template>
  <div>
    <Page auto-content-height>
      <FosoCard :showheader="false" class="!px-0 !pt-0">
        <FosoForm
          ref="formRef"
          :form-columns="formColumns"
          :form-columns-num="8"
          :form-data="formData"
          :form-expand="true"
          label-width="auto"
        />
      </FosoCard>
      <Grid>
        <!-- 使用 toolbar-buttons 插槽添加自定义按钮 -->
        <template #toolbar-buttons>
          <el-button class="ml-auto" type="primary"> 新增接口 </el-button>
        </template>
      </Grid>
    </Page>
  </div>
</template>

<script setup lang="ts">
import { Page } from '@vben/common-ui';

import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { useTable } from '#/hooks/usetable';
// 表单实例
const formRef = ref();
// 表单数据
const formData = ref({
  dictname: '',
});
// 表单配置项
const formColumns = ref([
  {
    label: '字典名称',
    prop: 'dictname',
    span: 8,
    xType: 'Input',
    componentProps: {
      placeholder: '请输入',
      clearable: true,
    },
  },
]);
// 表格配置项
const { tableconfig } = useTable({
  columns: [
    { type: 'checkbox', width: 80 },
    { field: 'name', title: '展示名称' },
    { field: 'sex', title: '字典名称' },
    { field: 'age', title: '状态' },
    { field: 'role', title: '创建时间', width: 180 },
    { field: 'address', title: 'Address', showOverflow: true },
  ],
  data: [
    {
      id: 10_001,
      role: 'Develop',
      sex: 'Man',
      age: 28,
      name: 'John',
      address: 'test abc',
    },
    {
      id: 10_002,
      role: 'Test',
      sex: 'Women',
      age: 22,
      name: 'John',
      address: 'Guangzhou',
    },
    {
      id: 10_003,
      role: 'PM',
      sex: 'Man',
      age: 32,
      name: 'John',
      address: 'Shanghai',
    },
    {
      id: 10_004,
      role: 'Designer',
      sex: 'Women',
      age: 23,
      name: 'John',
      address: 'test abc',
    },
    {
      id: 10_005,
      role: 'Develop',
      sex: 'Women',
      age: 30,
      name: 'John',
      address: 'Shanghai',
    },
  ],
});
// 表格事件
const gridEvents = {};
// 表格实例
const [Grid] = useVbenVxeGrid({ gridEvents, gridOptions: tableconfig.value });
</script>

<style scoped></style>
